package ace.oauth2.rpc.contract;

import ace.fw.model.R;
import ace.oauth2.model.dto.OAuth2TokenDto;
import ace.oauth2.model.request.*;
import ace.oauth2.model.response.OAuth2CheckAccessTokenResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author Caspar
 * @contract 279397942@qq.com
 * @create 2020/1/14 12:29
 * @description oauth2 标准接口 服务端与客户端契约
 */
@Validated
public interface OAuth2RpcContract {

    /**
     * 根据会员账号ID 创建 oauth2 token
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/rpc/oauth2/token")
    @ApiOperation(value = "根据会员账号ID 创建 oauth2 token")
    R<OAuth2TokenDto> createToken(@Valid @RequestBody OAuth2CreateTokenRequest request);

    /**
     * 刷新oauth2 token
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/rpc/oauth2/token/refresh")
    @ApiOperation(value = "刷新oauth2 token")
    R<OAuth2TokenDto> refreshToken(@Valid @RequestBody OAuth2RefreshTokenRequest request);

    /**
     * 删除 oauth2 token 根据 access token
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/rpc/oauth2/token/remove")
    @ApiOperation(value = "删除 oauth2 token 根据 access token")
    R<Boolean> removeToken(@Valid @RequestBody OAuth2RemoveTokenRequest request);

    /**
     * 验证 access token 是否有效
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/rpc/oauth2/token/check")
    @ApiOperation(value = "验证 access token 是否有效")
    R<OAuth2CheckAccessTokenResponse> checkAccessToken(@Valid @RequestBody OAuth2CheckAccessTokenRequest request);

    /**
     * 删除某个账户所有token信息
     *
     * @param request
     * @return
     */
    @PostMapping(value = "/rpc/oauth2/token/remove/all")
    @ApiOperation(value = "删除某个账户所有token信息")
    R<Boolean> removeAllTokenByAccountId(@Valid @RequestBody OAuth2RemoveAllTokenByAccountIdRequest request);

}
